package com.atguigu.lease.common.exception;

import com.atguigu.lease.common.result.Result;
import com.atguigu.lease.common.result.ResultCodeEnum;
import org.springframework.web.bind.annotation.ExceptionHandler;

/**
 * @BelongsProject: lease
 * @BelongsPackage: com.atguigu.lease.common.exception
 * @Author: 王席舒
 * @CreateTime: 2024-10-06  17:36
 * @Description: TODO
 * @Version: 1.0
 */
public class GlobalExceptionHandles {

    @ExceptionHandler(LeaseException.class)
    public Result leaseExceptionHandler(LeaseException e){
        e.printStackTrace();
        ResultCodeEnum resultCodeEnum = e.getResultCodeEnum();
        return  Result.build(null,resultCodeEnum);
    }

    @ExceptionHandler(Exception.class)
    public Result exception(Exception e){
        e.printStackTrace();
        return Result.fail();
    }
}
